﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Markup;

namespace PersonaLibrary.ViewModel.PrintViewModel
{
	internal class SinglePrintTemplate : BasePrintTemplate
	{
		protected override System.Windows.Documents.IDocumentPaginatorSource CreateTable(System.Windows.Size pageSize, System.Windows.Thickness thickness)
		{
			FixedDocument result = new FixedDocument();
			result.DocumentPaginator.PageSize = pageSize;

			ContentControl control = new ContentControl();
			control.Content = Items[0];

			double contentWidht = pageSize.Width - thickness.Left - thickness.Right;
			double contentHeight = pageSize.Height - thickness.Top - thickness.Bottom;

			control.Measure(new Size(contentWidht, contentHeight));
			control.ContentTemplate = (DataTemplate)App.Current.FindResource("EmployeeForPrint");
			control.Margin = thickness;

			PageContent page = new PageContent();
			FixedPage fixPage = new FixedPage();
			fixPage.Children.Add(control);
			((IAddChild)page).AddChild(fixPage);
			result.Pages.Add(page);

			return result;
		}

		public override void UnLoad()
		{
			
		}
	}
}
